package com.ethan.orika;

import com.google.common.collect.Lists;
import lombok.*;
import ma.glasnost.orika.MapperFactory;
import ma.glasnost.orika.impl.DefaultMapperFactory;

import java.util.List;

/**
 * @author ethan
 * create 2018-04-11 下午2:12
 * desc 集合映射
 **/
public class OrikaTest3 {
    public static void main(String[] args){
        MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
        mapperFactory.classMap(Person.class,PersonDto.class)
                .field("id","personId")
                .field("name","personName")
                .byDefault().register();
        List<Person> personList = Lists.newArrayList(new Person(1,"zs"),new Person(2,"ls"),new Person(3,"ww"));
        List<PersonDto> personDtoList = mapperFactory.getMapperFacade().mapAsList(personList,PersonDto.class);

        String a="";
    }

    @Setter
    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ToString
    public static class Person{
        private int id;
        private String name;
    }

    @Setter
    @Getter
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ToString
    public static class PersonDto{
        private int personId;
        private String personName;
    }
}
